package com.zheng.redpacket.server.controller.rabbitmq;

import com.zheng.redpacket.api.CommonResult;
import com.zheng.redpacket.api.ResultCode;
import com.zheng.redpacket.mdg.model.UserOrder;
import com.zheng.redpacket.server.dto.OrderDto;
import com.zheng.redpacket.server.serivce.Impl.UserOrderServiceImpl;
import com.zheng.redpacket.server.serivce.UserOrderService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/order")
public class UserOrderController {
    private static final Logger LOGGER = LoggerFactory.getLogger(UserOrderController.class);

    @Autowired
    private UserOrderService userOrderService;

    @PostMapping("/push")
    public CommonResult login(@RequestBody OrderDto dto){
        try {
            userOrderService.pushUserOrder(dto);
            return new CommonResult(ResultCode.SUCCESS);
        } catch (Exception e) {
            LOGGER.error("操作失败", e.fillInStackTrace());
            return new CommonResult(ResultCode.FAILED);
        }
    }
}
